#include <stdio.h>
#include <stdlib.h>

FILE *open_data(void);
int *getint();

int main(void) {
    FILE *fp;
    char buf[1024];
    printf("fp address is %p\n", fp);
    fp= open_data();
    printf("fp address is %p\n", fp);

    printf("file content: \n");
    while (fgets(buf, 1024, fp) != NULL)
        printf("%s", buf);

    return 0;
}

FILE * open_data(void) {
    FILE *fp;
    char databuf[BUFSIZ];

    if ((fp = fopen("test.c", "r")) == NULL)
        return(NULL);
    if (setvbuf(fp, databuf, _IOLBF, BUFSIZ) != 0)
        return(NULL);

    return(fp);
}
